Skip to content

Read the column names from the first existing step 3 result file - #143

Merged
kriboe90 merged 1 commit into
masterfrom
develop_analysis_first_result_file
Oct 27, 2026
Merged

kriboe90 merged 1 commit into
masterfrom
develop_analysis_first_result_file

Conversation

@kriboe90

Copy link
Copy Markdown
Contributor

Problem

_get_column_names reads the column names of the step 3 result files from analysis/channelN/1_led_positions.csv, while create_binary_data leaves images without results out of the binary. An image that could not be read has no result file at all, so if image 1 is the unreadable one, --analysis stops before reaching the loop that would leave it out:

FileNotFoundError: analysis/channel0/1_led_positions.csv not found.

Reported by Manuel Osburg in #131, who hit it while checking the interplay with #137. It is not specific to corrupted images: any channel whose lowest analysed image ID is not 1 runs into it.

Change

A new _find_first_result_file collects the image IDs of the {id}_led_positions.csv files of a channel, compares them as numbers (so 2 comes before 10) and returns the path of the lowest one. _get_column_names reads the names from that file. A channel without any result file now raises a FileNotFoundError naming the directory and saying to run the data extraction first, instead of numpy's bare 1_led_positions.csv not found.

The regex that matches the result files is duplicated from _find_analysed_img_ids in step_3_functions, which cannot be imported here because it imports read_table from this module.

Create And Fill Config Analysis gained a num_ref_images argument, which defaults to the 1 it used so far.

Not covered: image 1 is also the default reference image. With num_ref_images = 1 and no results for image 1 the reference intensities come back empty, which this change does not address — whether a missing reference image should fall back or fail loudly is a separate question.

Verification

  • Acceptance suite: 18/18 pass, including a new case in 07_test_corrupted_images.robot that truncates test_img_1.jpg, runs -s3_fast and --analysis, and asserts that the coefficients leave image 1 out while every remaining image keeps its own experiment time. It takes the reference from image 2, for the reason above.
  • Unit tests: 25/25 pass, six of them new in ledsa/tests/UnitTests/test_file_handling.py: numeric ordering of the IDs, a missing image 1, other files in the directory ignored, an empty channel, a missing channel directory, and _get_column_names on a channel whose first result file is image 2.
  • Checked the failure before the change: a channel holding only 2_led_positions.csv raises the FileNotFoundError quoted above, and returns the column names with the change.

🤖 Generated with Claude Code

_get_column_names read analysis/channelN/1_led_positions.csv, while
create_binary_data leaves images without results out of the binary. An
image that could not be read has no result file at all, so if image 1 was
the unreadable one, --analysis stopped with a FileNotFoundError for that
file instead of leaving the image out. The names are now read from the
result file with the lowest image ID, and a channel without any result
file raises a FileNotFoundError that says to run the data extraction
first.

The acceptance test takes the reference intensities from image 2, because
image 1 is the default reference image and has no results in that test.

Reported by Manuel Osburg in #131.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kriboe90
kriboe90 merged commit 0401065 into master Oct 27, 2026
5 checks passed
@kriboe90
kriboe90 deleted the develop_analysis_first_result_file branch October 27, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant